<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
const kStyle = [
    'font-family: monospace;',
    'width: 4ch',
].join(' ');

// LTR
selection_test(
    [
        `<div contenteditable style="${kStyle}">`,
            '|abc def ghi jkl',
        '</div>',
    ],
    selection => selection.modify("move", "forward", "line"),
    [
        `<div contenteditable style="${kStyle}">`,
            'abc |def ghi jkl',
        '</div>',
    ], 'LTR move forward line');
selection_test(
    [
        `<div contenteditable style="${kStyle}">`,
            'abc |def ghi jkl',
        '</div>',
    ],
    selection => selection.modify("extend", "forward", "lineboundary"),
    [
        `<div contenteditable style="${kStyle}">`,
            'abc ^def |ghi jkl',
        '</div>',
    ], 'LTR extend forward lineboundary');

// RTL-BDO
selection_test(
    [
        `<div contenteditable dir="rtl" style="${kStyle}">`,
            '<bdo dir="rtl">|abc def ghi jkl</bdo>',
        '</div>',
    ],
    selection => selection.modify("move", "forward", "line"),
    [
        `<div contenteditable dir="rtl" style="${kStyle}">`,
            '<bdo dir="rtl">abc |def ghi jkl</bdo>',
        '</div>',
    ], 'RTL-BDO move forward line');
selection_test(
    [
        `<div contenteditable dir="rtl" style="${kStyle}">`,
            '<bdo dir="rtl">abc |def ghi jkl</bdo>',
        '</div>',
    ],
    selection => selection.modify("extend", "forward", "lineboundary"),
    [
        `<div contenteditable dir="rtl" style="${kStyle}">`,
            '<bdo dir="rtl">abc ^def |ghi jkl</bdo>',
        '</div>',
    ], 'RTL-BDO extend forward lineboundary');

// RTL
selection_test(
    [
        `<div contenteditable dir="rtl" style="${kStyle}">`,
            '|\u05D0\u05D1\u05D2 \u05E0\u05E1\u05E2 \u05E5\u05E6\u05E7 \u05D5\u05D6\u05D7',
        '</div>',
    ],
    selection => selection.modify("move", "forward", "line"),
    [
        `<div contenteditable dir="rtl" style="${kStyle}">`,
            '\u05D0\u05D1\u05D2 |\u05E0\u05E1\u05E2 \u05E5\u05E6\u05E7 \u05D5\u05D6\u05D7',
        '</div>',
    ], 'RTL move forward line');
selection_test(
    [
        `<div contenteditable dir="rtl" style="${kStyle}">`,
            '\u05D0\u05D1\u05D2 |\u05E0\u05E1\u05E2 \u05E5\u05E6\u05E7 \u05D5\u05D6\u05D7',
        '</div>',
    ],
    selection => selection.modify("extend", "forward", "lineboundary"),
    [
        `<div contenteditable dir="rtl" style="${kStyle}">`,
            '\u05D0\u05D1\u05D2 ^\u05E0\u05E1\u05E2 |\u05E5\u05E6\u05E7 \u05D5\u05D6\u05D7',
        '</div>',
    ], 'RTL extend forward lineboundary');
</script>
